export enum ApiErrorCode {
  INTERNAL_ERROR = "INTERNAL_ERROR",
  FEED_INVALID = "FEED_INVALID",
  NO_FEED_IN_HTML_PAGE = "NO_FEED_IN_HTML_PAGE",
  FEED_INVALID_SSL_CERT = "FEED_INVALID_SSL_CERT",
  FEED_PARSE_FAILED = "FEED_PARSE_FAILED",
  FEED_FETCH_FAILED = "FEED_FETCH_FAILED",
  ADD_FEED_PARSE_FAILED = "ADD_FEED_PARSE_FAILED",
  FEED_PARSE_TIMEOUT = "FEED_PARSE_TIMEOUT",
  FEED_REQUEST_TIMEOUT = "FEED_REQUEST_TIMEOUT",
  FEED_REQUEST_FAILED = "FEED_REQUEST_FAILED",
  FEED_REQUEST_FORBIDDEN = "FEED_REQUEST_FORBIDDEN",
  FEED_REQUEST_INTERNAL_ERROR = "FEED_REQUEST_INTERNAL_ERROR",
  FEED_REQUEST_TOO_MANY_REQUESTS = "FEED_REQUEST_TOO_MANY_REQUESTS",
  FEED_REQUEST_UNAUTHORIZED = "FEED_REQUEST_UNAUTHORIZED",
  FEED_CONNECTION_NOT_FOUND = "FEED_CONNECTION_NOT_FOUND",
  WEBHOOKS_MANAGE_MISSING_PERMISSIONS = "WEBHOOKS_MANAGE_MISSING_PERMISSIONS",
  WEBHOOKS_DISABLED = "WEBHOOKS_DISABLED",
  WEBHOOK_MISSING = "WEBHOOK_MISSING",
  WEBHOOK_INVALID = "WEBHOOK_INVALID",
  FEED_MISSING_CHANNEL_PERMISSION = "FEED_MISSING_CHANNEL_PERMISSION",
  FEED_MISSING_VIEW_CHANNEL_PERMISSION = "FEED_MISSING_VIEW_CHANNEL_PERMISSION",
  FEED_MISSING_CHANNEL = "FEED_MISSING_CHANNEL",
  FEED_USER_MISSING_MANAGE_GUILD = "FEED_USER_MISSING_MANAGE_GUILD",
  FEED_LIMIT_REACHED = "FEED_LIMIT_REACHED",
  FEED_NOT_FAILED = "FEED_NOT_FAILED",
  FEED_NOT_FOUND = "FEED_NOT_FOUND",
  FEED_TOO_LARGE = "FEED_TOO_LARGE",
  ADD_FEED_WITH_SOURCE_FEED_NOT_FOUND = "ADD_FEED_WITH_SOURCE_FEED_NOT_FOUND",
  FEED_INVALID_FILTER_EXPRESSION = "FEED_INVALID_FILTER_EXPRESSION",
  FEED_INVALID_COMPONENTS_V2 = "FEED_INVALID_COMPONENTS_V2",
  BANNED_FEED = "BANNED_FEED",
  DISCORD_CHANNEL_NOT_OWNED_BY_GUILD = "DISCORD_CHANNEL_NOT_OWNED_BY_GUILD",
  DISCORD_CAHNNEL_INVALID = "DISCORD_CAHNNEL_INVALID",
  FEED_CONNECTION_CANNOT_ENABLE_AUTO_DISABLED = "FEED_CONNECTION_CANNOT_ENABLE_AUTO_DISABLED",
  FEED_ARTICLE_NOT_FOUND = "FEED_ARTICLE_NOT_FOUND",
  DISCORD_SERVER_NOT_FOUND = "DISCORD_SERVER_NOT_FOUND",
  WEBHOOK_FORUM_UNSUPPORTED = "WEBHOOK_FORUM_UNSUPPORTED",
  ALREADY_CONVERTED_TO_USER_FEED = "ALREADY_CONVERTED_TO_USER_FEED",
  LEGACY_CONVERSION_JOB_EXISTS = "LEGACY_CONVERSION_JOB_EXISTS",
  NO_LEGACY_FEEDS_TO_CONVERT = "NO_LEGACY_FEEDS_TO_CONVERT",
  HANDLED_BY_BULK_CONVERSION = "HANDLED_BY_BULK_CONVERSION",
  CANNOT_RESTORE_LEGACY_FEED = "CANNOT_RESTORE_LEGACY_FEED",
  MISSING_SHARED_MANAGER_PERMISSIONS = "MISSING_SHARED_MANAGER_PERMISSIONS",
  USER_MANAGER_ALREADY_INVITED = "USER_MANAGER_ALREADY_INVITED",
  USER_FEED_TRANSFER_REQUEST_EXISTS = "USER_FEED_TRANSFER_REQUEST_EXISTS",
  INSUFFICIENT_SUPPORTER_LEVEL = "INSUFFICIENT_SUPPORTER_LEVEL",
  INVALID_CUSTOM_PLACEHOLDERS_REGEX_PREVIEW_INPUT = "INVALID_CUSTOM_PLACEHOLDERS_REGEX_PREVIEW_INPUT",
  INVALID_FILTERS_REGEX = "INVALID_FILTERS_REGEX",
  TRANSACTION_BALANCE_TOO_LOW = "TRANSACTION_BALANCE_TOO_LOW",
  SUBSCRIPTION_ABOUT_TO_RENEW = "SUBSCRIPTION_ABOUT_TO_RENEW",
  USER_REFRESH_RATE_NOT_ALLOWED = "USER_REFRESH_RATE_NOT_ALLOWED",
}

// Create a package for the frontend?

export const API_ERROR_MESSAGES: Record<ApiErrorCode, string> = {
  FEED_INVALID: "Invalid feed",
  FEED_PARSE_FAILED: "Failed to parse feed",
  FEED_FETCH_FAILED: "Failed to fetch feed",
  NO_FEED_IN_HTML_PAGE: "No feed found in HTML page",
  ADD_FEED_PARSE_FAILED: "Failed to parse feed",
  FEED_PARSE_TIMEOUT: "Failed to parse feed due to timeout",
  FEED_REQUEST_TIMEOUT: "Failed to request feed due to timeout",
  FEED_REQUEST_FAILED: "Failed to request feed",
  INTERNAL_ERROR: "Internal error",
  FEED_REQUEST_FORBIDDEN: "Request to feed failed (403 code)",
  FEED_REQUEST_INTERNAL_ERROR: "Request to feed failed (5xx code)",
  FEED_REQUEST_TOO_MANY_REQUESTS: "Request to feed failed (429 code)",
  FEED_REQUEST_UNAUTHORIZED: "Request to feed failed (401 code)",
  FEED_CONNECTION_NOT_FOUND: "Feed connection was not found",
  WEBHOOKS_MANAGE_MISSING_PERMISSIONS:
    "Bot is missing Manage Webhooks permission",
  WEBHOOKS_DISABLED: "Webhooks are not enabled",
  WEBHOOK_MISSING: "Specified webhook does not exist",
  WEBHOOK_INVALID:
    'Specified webhook is invalid. Must be of type "Incoming Webhook"' +
    " that has not been created by another application",
  FEED_MISSING_CHANNEL: "Channel does not exist",
  FEED_MISSING_CHANNEL_PERMISSION: "Insufficient bot permissions in channel",
  FEED_MISSING_VIEW_CHANNEL_PERMISSION:
    "Bot is missing View Channel permission",
  FEED_USER_MISSING_MANAGE_GUILD: "User is missing Manage Server permission",
  FEED_LIMIT_REACHED: "Feed limit reached",
  BANNED_FEED: "Feed is banned",
  DISCORD_CHANNEL_NOT_OWNED_BY_GUILD:
    "Channel is not owned by the current guild",
  DISCORD_CAHNNEL_INVALID: "Selected channel is not accepted",
  FEED_NOT_FAILED:
    "The feed is not in a failed state. It must be in a failed state for it to be retried.",
  FEED_NOT_FOUND:
    "Feed does not exist or is not accessible. You may confirm by directly going to the feed link and checking that the feed is valid and publicly accessible.",
  FEED_TOO_LARGE: "Feed is too large to be processed",
  FEED_INVALID_FILTER_EXPRESSION: "Invalid filter expression",
  FEED_INVALID_COMPONENTS_V2: "Invalid componentsV2 configuration",
  FEED_CONNECTION_CANNOT_ENABLE_AUTO_DISABLED:
    "Cannot enable a feed that was automatically disabled",
  FEED_ARTICLE_NOT_FOUND: "Article does not exist",
  DISCORD_SERVER_NOT_FOUND:
    "Server does not exist or bot does not have access to server",
  WEBHOOK_FORUM_UNSUPPORTED: "Forum webhooks are currently unsupported",
  ALREADY_CONVERTED_TO_USER_FEED:
    "Feed has already been converted to a user feed",
  LEGACY_CONVERSION_JOB_EXISTS:
    "A legacy conversion job already exists for this feed",
  NO_LEGACY_FEEDS_TO_CONVERT: "No legacy feeds to convert",
  HANDLED_BY_BULK_CONVERSION: "Handled by bulk conversion",
  CANNOT_RESTORE_LEGACY_FEED: "Feed is ineligible for legacy restoration",
  MISSING_SHARED_MANAGER_PERMISSIONS:
    "You are missing the required permissions to do this action.",
  USER_MANAGER_ALREADY_INVITED: "Invitation exists for this user.",
  USER_FEED_TRANSFER_REQUEST_EXISTS:
    "Transfer request already exists for this feed.",
  INSUFFICIENT_SUPPORTER_LEVEL: "Insufficient supporter level",
  INVALID_CUSTOM_PLACEHOLDERS_REGEX_PREVIEW_INPUT:
    "Invalid preview input in regex search for custom placeholders",
  INVALID_FILTERS_REGEX: "Invalid filters regex",
  FEED_INVALID_SSL_CERT: "Invalid SSL certificate on feed site",
  ADD_FEED_WITH_SOURCE_FEED_NOT_FOUND: "Source feed not found",
  TRANSACTION_BALANCE_TOO_LOW: "Transaction balance is too low.",
  SUBSCRIPTION_ABOUT_TO_RENEW:
    "Subscription is about to renew. Wait at least 30 minutes before trying again.",
  USER_REFRESH_RATE_NOT_ALLOWED: "Refresh rate not allowed",
};
